import axiosInstance from '@/utils/request'

/**
 * 获取用户的所有地址
 * @param {number} userId - 用户ID
 * @returns {Promise} Axios Promise
 */
export const getAddressesByUserIdAPI = (userId) => {
    return axiosInstance.get(`/product/address/user/${userId}`)
}

/**
 * 添加用户地址
 * @param {Object} addressDTO - 地址信息
 * @returns {Promise} Axios Promise
 */
export const addAddressAPI = (addressDTO) => {
    return axiosInstance.post('/product/address', addressDTO)
}

/**
 * 更新用户地址
 * @param {number} addressId - 地址ID
 * @param {Object} addressDTO - 地址信息
 * @returns {Promise} Axios Promise
 */
export const updateAddressAPI = (addressId, addressDTO) => {
    return axiosInstance.put(`/product/address/${addressId}`, addressDTO)
}

/**
 * 删除用户地址
 * @param {number} addressId - 地址ID
 * @returns {Promise} Axios Promise
 */
export const deleteAddressAPI = (addressId) => {
    return axiosInstance.delete(`/product/address/${addressId}`)
}

/**
 * 获取地址详情
 * @param {number} addressId - 地址ID
 * @returns {Promise} Axios Promise
 */
export const getAddressByIdAPI = (addressId) => {
    return axiosInstance.get(`/product/address/${addressId}`)
}

/**
 * 设置默认地址
 * @param {number} addressId - 地址ID
 * @param {number} userId - 用户ID
 * @returns {Promise} Axios Promise
 */
export const setDefaultAddressAPI = (addressId, userId) => {
    return axiosInstance.put(`/product/address/setDefault/${addressId}/${userId}`)
}